package com.woniuxy.springcloud.consumer.student;


import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

/**
 * description: ConsumerStudent7071Application <br>
 * date: 2022/1/20 3:51 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */

//启用服务发现:去服务器获取调用地址
//使用Ribbon调用不要服务发现
//@EnableDiscoveryClient
@EnableFeignClients  //启用OpenFeign
//启动hystrix
@EnableHystrix
@EnableEurekaClient
@SpringBootApplication
public class ConsumerStudent7071Application {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerStudent7071Application.class, args);
    }

    //添加Dashboard启动类，底层要Servlet
    @Bean
    public ServletRegistrationBean getServlet() {
        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean registrationBean =
                new ServletRegistrationBean(streamServlet);
        registrationBean.setLoadOnStartup(1);
        registrationBean.addUrlMappings("/hystrix.stream");
        registrationBean.setName("HystrixMetricsStreamServlet");
        return registrationBean;
    }
}